<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body {
        perspective: 500px;
      }
      .box {
        transform-style: preserve-3d;
        position: relative;
        width: 200px;
        height: 30px;
        margin: 200px auto;
        transition: all 0.4s;
      }
      .box:hover {
        transform: rotateX(90deg);
      }
      .box .son2 {
        position: absolute;
        top: 0;
        left: 0;
        width: 200px;
        height: 30px;
        background-color: cadetblue;
        transform: translateY(15px) rotateX(-90deg);
      }
      .son1 {
        position: absolute;
        width: 200px;
        height: 30px;
        background-color: blueviolet;
        transform: translateZ(15px);
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="son1">123</div>
      <div class="son2">123</div>
    </div>
  </body>
</html>
